<?php
/** @var OportunidadController $this */
/** @var Oportunidad $model */
/** @var AweActiveForm $form */
// Prevenir que jquery se cargue dos veces
Yii::app()->clientScript->scriptMap['jquery.js'] = false;
Yii::app()->clientScript->scriptMap['jquery.yiigridview.js'] = false;
//Util::tsRegisterAssetJs('_form.js');
Util::tsRegisterAssetJs('_form_modal.js');
/** @var CampaniaController $this */
?>
<div class="modal-header">
    <a class="close" data-dismiss="modal">&times;</a>
    <h4><i class="icon-tag"></i> Grupos Contacto </h4>
</div>
<div class="modal-body">
    <center>    
        <?php
        $this->widget('ext.bootstrap.widgets.TbToggleButton', array(
            'name' => 'allClient_toggle',
            'disabledLabel' => 'Por Contacto',
            'enabledLabel' => 'Por Grupo',
            'width' => 200,
            'value' => true,
            'enabledStyle' => 'warning',
            'disabledStyle' => 'primary',
            'onChange' => 'js:function($el, status, e){ activarGrid(status); }'
                )
        );
        ?>
    </center>
    <div id="grupo" >
        <div class = "widget orange">
            <div class = "widget-title">
                <h4> Grupo Cuentas</h4>
                <!--<h4><i class = "icon-archive"></i> Grupo Cuentas</h4>-->
                <span class = "tools">
                    <!--<a href = "javascript:;" class = "icon-chevron-down"></a>-->
                    <!--<a href="javascript:;" class="icon-remove"></a>-->
                </span>
            </div>
            <div class = "widget-body ">
                <?php
                $this->widget('ext.bootstrap.widgets.TbGridView', array(
                    'id' => 'addCampaniaCuentaGrupos-grid',
//                    'id' => 'addCampaniaGrupos-grid',
                    "template" => "{items}{pager}",
                    'afterAjaxUpdate' => "function(id,data){updateCheckedRaw('Gruposcuenta');loadActionSelect(); }",
                    'type' => '',
                    'dataProvider' => $gruposCuentas,
                    'columns' => array(
                        array(
                            'name' => '<input type="checkbox"  id="selectall" value="all" container = Gruposcuenta >',
                            'type' => 'raw',
                            'value' => '"<input type=\"checkbox\" id=\"ckb_".$data->id."\" class=\"ckeckRow\" value=\"$data->id\" container = Gruposcuenta >"',
                        ),
                        array(
                            'header' => 'Grupo',
                            'value' => '$data->nombreGrupo',
                            'type' => 'raw',
                        ),
//                        array(
//                            'value' => '$data->numCuentas',
//                            'type' => 'raw',
//                        ),
                    ),
                ));
                ?>
            </div>
        </div>
        <div class = "widget bluesky">
            <div class = "widget-title">
                <h4> Grupos Contacto</h4>
<!--                <h4><i class = "icon-archive"></i> Grupos Contacto</h4>-->
                <span class = "tools">
                    <!--                    <a href = "javascript:;" class = "icon-chevron-down"></a>
                                        <a href="javascript:;" class="icon-remove"></a>-->
                </span>
            </div>
            <div class = "widget-body ">
                <?php
                $this->widget('ext.bootstrap.widgets.TbGridView', array(
                    'id' => 'addCampaniaContactoGrupos-grid',
                    "template" => "{items}{pager}",
                    'afterAjaxUpdate' => "function(id,data){updateCheckedRaw('Gruposcontacto');loadActionSelect();}",
                    'type' => '',
                    'dataProvider' => $gruposContactos,
                    'columns' => array(
                        array(
                            'name' => '<input type="checkbox"  id="selectall" value="all" container = Gruposcontacto >',
                            'type' => 'raw',
                            'value' => '"<input type=\"checkbox\" id=\"ckb_".$data->id."\" class=\"ckeckRow\" value=\"$data->id\" container = Gruposcontacto >"',
                        ),
                        array(
                            'header' => 'Grupo',
                            'value' => '$data->nombreGrupo',
                            'type' => 'raw',
                        ),
//                        array(
//                            'value' => '$data->numCuentas',
//                            'type' => 'raw',
//                        ),
                    ),
                ));
                ?>
            </div>
        </div>


    </div>
    <div id="cuenta" class="hidden">
        <br>
        <?php
        $this->widget('ext.Truulo.TruuloModuleSearch', array(
            'model' => $model,
            'grid_id' => 'campania-cuenta-grids',
            'id' => 'form_modal',
            'nameInput' => 'input_modal',
            'idList' => 'sel_modal'
                )
        );
        ?>
        <?php
        $this->widget('ext.bootstrap.widgets.TbGridView', array(
            'id' => 'campania-cuenta-grids',
            "template" => "{items}{pager}",
            'afterAjaxUpdate' => "function(id,data){updateCheckedRaw('Cuentas'); loadActionSelect();}",
            'type' => 'striped bordered hover advance',
            'dataProvider' => $model->searchContactoNoCampania($id_campania),
            'columns' => array(
                array(
                    'name' => '<input type="checkbox"  id="selectall" value="all" container = Cuentas >',
                    'type' => 'raw',
                    'value' => '"<input type=\"checkbox\" id=\"ckb_".$data->id."\" class=\"ckeckRow\" value=\"$data->id\" container = Cuentas>"',
                ),
                array(
                    'name' => 'nombre_completo',
                    'value' => '$data->nombre_completo'
                ),
                array(
                    'header' => 'Cuenta',
                    'name' => 'cuenta_id',
                    'value' => '$data->cuenta?$data->cuenta->nombre:""'
                ),
                array(
                    'name' => 'cargo',
                    'value' => '$data->cargo'
                ),
            ),
        ));
        ?>

    </div>

</div>
</div>
<div class="modal-footer">
    <?php
    $this->widget('bootstrap.widgets.TbButton', array(
        'type' => 'success',
        'icon' => 'ok',
        'label' => $model->isNewRecord ? Yii::t('AweCrud.app', 'Agregar') : Yii::t('AweCrud.app', 'Save'),
        'htmlOptions' => array(
            'onClick' => 'js:ajaxAgregar()')
    ));
    ?>
    <?php
    $this->widget('bootstrap.widgets.TbButton', array(
        'icon' => 'remove',
        'label' => Yii::t('AweCrud.app', 'Cancel'),
        'htmlOptions' => array(
            'data-dismiss' => 'modal',)
    ));
    ?>
</div>

